import { http } from '@/utils/http/axios';
import {ContentTypeEnum, RequestEnum} from "@/enums/httpEnum";

/**
 * Markdown图床
 */
export const upload2MarkdownPicture = file => {
  return http.request({
    url: '/picture/markdown',
    method: RequestEnum.POST,
    headers: {
      'Content-Type': ContentTypeEnum.FORM_DATA
    },
    data: {
      file: file
    }
  })
}

/**
 * 用户图床
 */
export const upload2Picture = file => {
  return http.request({
    url: '/picture/manual',
    method: RequestEnum.POST,
    headers: {
      'Content-Type': ContentTypeEnum.FORM_DATA
    },
    data: {
      file: file
    }
  })
}

/**
 * 图床分页数据
 */
export const getPicturePage = ({pageNum, pageSize}) => {
  return http.request({
    url: `/picture/page/${pageNum}/${pageSize}`,
    method: RequestEnum.GET
  })
}

/**
 * 从图床移除
 */
export const removePicture = (id: string) => {
  return http.request({
    url: `/picture/remove/${id}`,
    method: RequestEnum.DELETE
  }, {
    isShowSuccessMessage: true
  })
}
